/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package attackDetection2;
import java.util.*;
/**
 *
 * @author john
 */
public class Message {
    private int messageId;
    private int sourceNodeId;
    private int destinationNodeId;
    private int ttl;
    private ArrayList<Packet> packetList;
    private ArrayList<Packet> dropList;
    private HashMap<Integer,Packet> packetSequence;



    public Message(Packet p){
        messageId = p.getMessageId();
        packetSequence = new HashMap<Integer,Packet>();
        packetList = new ArrayList<Packet>();
        dropList = new ArrayList<Packet>();
        sourceNodeId = 0;
        destinationNodeId = 0;
        
        // add(p);
    }

    public Message(Packet p, int ttl){
        this.ttl = ttl;
        // Call other contructor
    }

    public void add(Packet p){
        // Fix the implementation of Packet to include my additions
        if(!packetSequence.containsKey(p));
            // packetSequence.put(p.getSeqeunceNumber(), p);
    }

    public void addPacket(Packet p){
        getPacketList().add(p);
    }

    @Override
    public String toString(){
        String out = "";
        out += "Message ID: " + this.getMessageId() + "\n";
        out += "Outputting packets for sequence number \n";
        out += packetSequence.toString() + "\n";

        return out;
    }

    /**
     * @return the messageId
     */
    public int getMessageId() {
        return messageId;
    }

    /**
     * @param messageId the messageId to set
     */
    public void setMessageId(int messageId) {
        this.messageId = messageId;
    }

    /**
     * @return the sourceNodeId
     */
    public int getSourceNodeId() {
        return sourceNodeId;
    }

    /**
     * @param sourceNodeId the sourceNodeId to set
     */
    public void setSourceNodeId(int sourceNodeId) {
        this.sourceNodeId = sourceNodeId;
    }

    /**
     * @return the destinationNodeId
     */
    public int getDestinationNodeId() {
        return destinationNodeId;
    }

    /**
     * @param destinationNodeId the destinationNodeId to set
     */
    public void setDestinationNodeId(int destinationNodeId) {
        this.destinationNodeId = destinationNodeId;
    }

    /**
     * @return the ttl
     */
    public int getTtl() {
        return ttl;
    }

    /**
     * @param ttl the ttl to set
     */
    public void setTtl(int ttl) {
        this.ttl = ttl;
    }

    /**
     * @return the packetList
     */
    public ArrayList<Packet> getPacketList() {
        return packetList;
    }

    /**
     * @param packetList the packetList to set
     */
    public void setPacketList(ArrayList<Packet> packetList) {
        this.packetList = packetList;
    }

    /**
     * @return the dropList
     */
    public ArrayList<Packet> getDropList() {
        return dropList;
    }

    /**
     * @param dropList the dropList to set
     */
    public void setDropList(ArrayList<Packet> dropList) {
        this.dropList = dropList;
    }

    /**
     * @return the packetSequence
     */
    public HashMap<Integer, Packet> getPacketSequence() {
        return packetSequence;
    }

    /**
     * @param packetSequence the packetSequence to set
     */
    public void setPacketSequence(HashMap<Integer, Packet> packetSequence) {
        this.packetSequence = packetSequence;
    }



}
